package com.github.elliot.usercenter.dao;

import com.github.elliot.usercenter.po.Role;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;

import java.util.List;

@Repository
public interface RoleRepository extends R2dbcRepository<Role, Integer>, UserInnerRepository {

    @Query("select b.backend_url from role_rel_permission a left join permission b on a.permission_no = b.permission_no where a.role_no in (:roleList)")
    Flux<String> getBackendUrlByRoleList(List<String> roleList);

    @Query("select a.role_no from user_rel_role a where a.user_no = :userNo")
    Flux<String> getRoleListByUserNo(String userNo);

}
